#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    my_tcp = aes_tcp_lib::create_aes_tcp();
    my_tcp->lus_set_order(LITTLE);
    my_tcp->lus_set_debug(true);
    my_tcp->aes_tcp_init();
//消息处理
    connect(my_tcp, SIGNAL(read_msg(QByteArray)), this, SLOT(read_tcp_msg(QByteArray)));
    //
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::read_tcp_msg(QByteArray msg)
{
    ui->textBrowser->append(msg);

}

void MainWindow::on_pushButton_send_clicked()
{
    my_tcp->lus_send_user_msg("test", "",ui->lineEdit->text());

}

void MainWindow::on_pushButton_debug_clicked()
{
   //my_tcp->debug_switch = !my_tcp->debug_switch;
}

void MainWindow::on_pushButton_pool_clicked()
{
   my_tcp->lus_down_pool_file("t", "test", "test.dat");
}

void MainWindow::on_pushButton_cnt_file_clicked()
{
          QString cmd_str = "<lus_requst";
          cmd_str += (" id=\"1\"");
          cmd_str += (" group_id=\"1\"");
          cmd_str += (" type=\"kernel_down\"");
          cmd_str += "/>";
          my_tcp->lus_send_raw_msg(cmd_str.toLatin1(), ENCRYPT_YES);
}
